/**
*		@file VarTable.h
*		@brief VarTable class
*
*		@author Zhou Nan
*
*		@date 1/25/2012
*/

#ifndef VARTALBE_H
#define VARTALBE_H

#include "TNode.h"
#include "GNode.h"
#include "Utility.h"
#include <vector>
#include <set>
#include <queue>
#include <string>
#include <sstream>
using namespace std;

typedef int		VarIdx;
typedef string	VarName;
typedef vector<bool>	VarSet;

/**
*		Structure to store data entry
*/
struct VarEntry{	
	// variable index, start from 1
	VarIdx		var_idx;
	// variable name
	VarName		var_name;
};


class VarTable{
public:
	/**
	*		This method will return the number of VarEntries in VarTable
	*/
	static int	GetSize() {return vp_var_entries_.size();};

	/**
	*		If var_name already exists, this method will return the VarIdx of the existence
	*		Otherwise, this method will insert a new VarEntry and return its VarIdx
	*/
	static VarIdx		InsertVar(VarName var_name); 
	
	/**
	*		If var_name exists, this method will return its VarIdx
	*		Otherwise, it will return -1
	*/
	static VarIdx		GetVarIdx(VarName var_name);
	
	/**
	*		This method will return the VarName with var_idx
	*/
	static VarName		GetVarName(VarIdx var_idx);

	/**
	*		This method will return a string representation of VarTable
	*/
	static string		ToString();

private:
	static vector<VarEntry*>	vp_var_entries_;

	/**
	*		If var_name exists, this method will assign *pp_var_entry to that reference and return true
	*		Otherwise, it will returns false
	*/
	static bool			CheckVarNameExistence(VarName var_name, VarEntry** pp_var_entry);

	/**
	*		This method will return a reference to the VarEntry with proc_idx
	*/
	static VarEntry*	GetVarEntry(VarIdx proc_idx);
};

#endif